package love.yuanmengrobot.wuziqi.UIzjj;

import java.awt.event.*;
import love.yuanmengrobot.wuziqi.Util.Packsack;

import javax.swing.*;
import java.awt.*;
import java.util.HashMap;
/*
 * Created by JFormDesigner on Sun May 09 19:51:55 CST 2021
 */


/**
 * @author 1
 */
public class ShowPacksackPanel extends JPanel {
    Packsack packsack;
  public    JPanel panelMain;

    public JPanel getPanelMain() {
        return panelMain;
    }

    public void setPanelMain(JPanel panelMain) {
        this.panelMain = panelMain;
    }

    String relativePath = "src/love/yuanmengrobot/wuziqi/Images/";//图片相对路径
    public static void main(String[] args) {
        new ShowPacksackPanel();
    }
    public ShowPacksackPanel(Packsack packsack){
        this.packsack=packsack;
        initComponents();
    }
    public ShowPacksackPanel() {
        initComponents();
    }

    private void button1BackToActionPerformed(ActionEvent e) {
        // TODO add your code here
        panelMain.setVisible(true);
        setVisible(false);
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        panel1 = new JPanel();
        label5 = new JLabel();
        label6 = new JLabel();
        label7 = new JLabel();
        panel2 = new JPanel();
        label21 = new JLabel();
        label9 = new JLabel();
        label8 = new JLabel();
        panel3 = new JPanel();
        label22 = new JLabel();
        label11 = new JLabel();
        label12 = new JLabel();
        panel4 = new JPanel();
        label23 = new JLabel();
        label14 = new JLabel();
        label15 = new JLabel();
        label4 = new JLabel();
        button1 = new JButton();

        //======== this ========
        setLayout(null);

        //======== panel1 ========
        {
            panel1.setLayout(null);

            //---- label5 ----
            label5.setText("\u62e5\u6709\u79ef\u5206\uff1a");
            label5.setFont(label5.getFont().deriveFont(label5.getFont().getSize() + 9f));
            panel1.add(label5);
            label5.setBounds(450, 15, 110, 35);

            //---- label6 ----
            label6.setFont(label6.getFont().deriveFont(label6.getFont().getSize() + 9f));
            panel1.add(label6);
            label6.setBounds(570, 15, 90, 35);

            //---- label7 ----
            label7.setText("\u62e5\u6709\u9053\u5177");
            label7.setFont(label7.getFont().deriveFont(label7.getFont().getSize() + 9f));
            panel1.add(label7);
            label7.setBounds(40, 15, 110, 35);

            //======== panel2 ========
            {
                panel2.setBackground(new Color(214, 217, 223));
                panel2.setLayout(null);

                //---- label21 ----
                label21.setBackground(new Color(0, 204, 102));
                panel2.add(label21);
                label21.setBounds(0, 0, 65, 65);

                //---- label9 ----
                label9.setFont(label9.getFont().deriveFont(label9.getFont().getSize() + 3f));
                panel2.add(label9);
                label9.setBounds(505, 40, 40, 25);

                //---- label8 ----
                label8.setFont(label8.getFont().deriveFont(label8.getFont().getSize() + 3f));
                panel2.add(label8);
                label8.setBounds(115, 0, 325, 65);
            }
            panel1.add(panel2);
            panel2.setBounds(60, 65, 595, 65);

            //======== panel3 ========
            {
                panel3.setBackground(new Color(214, 217, 223));
                panel3.setLayout(null);

                //---- label22 ----
                label22.setBackground(new Color(0, 204, 102));
                panel3.add(label22);
                label22.setBounds(0, 0, 65, 65);

                //---- label11 ----
                label11.setFont(label11.getFont().deriveFont(label11.getFont().getSize() + 3f));
                panel3.add(label11);
                label11.setBounds(115, 0, 325, 65);

                //---- label12 ----
                label12.setFont(label12.getFont().deriveFont(label12.getFont().getSize() + 3f));
                panel3.add(label12);
                label12.setBounds(505, 40, 40, 25);
            }
            panel1.add(panel3);
            panel3.setBounds(60, 175, 595, 65);

            //======== panel4 ========
            {
                panel4.setBackground(new Color(214, 217, 223));
                panel4.setLayout(null);

                //---- label23 ----
                label23.setBackground(new Color(0, 204, 102));
                panel4.add(label23);
                label23.setBounds(0, 0, 65, 65);

                //---- label14 ----
                label14.setFont(label14.getFont().deriveFont(label14.getFont().getSize() + 3f));
                panel4.add(label14);
                label14.setBounds(115, 0, 325, 65);

                //---- label15 ----
                label15.setFont(label15.getFont().deriveFont(label15.getFont().getSize() + 3f));
                panel4.add(label15);
                label15.setBounds(505, 35, 40, 25);
            }
            panel1.add(panel4);
            panel4.setBounds(60, 275, 595, 65);
        }
        add(panel1);
        panel1.setBounds(10, 55, 665, 350);

        //---- label4 ----
        label4.setText("\u80cc\u5305");
        label4.setFont(label4.getFont().deriveFont(label4.getFont().getSize() + 19f));
        add(label4);
        label4.setBounds(320, 5, 85, 45);

        //---- button1 ----
        button1.setText("\u8fd4\u56de");
        button1.addActionListener(e -> button1BackToActionPerformed(e));
        add(button1);
        button1.setBounds(new Rectangle(new Point(595, 20), button1.getPreferredSize()));

        setPreferredSize(new Dimension(680, 430));
        // JFormDesigner - End of component initialization  //GEN-END:initComponents


        HashMap<Integer,Object> mapImg=new HashMap<Integer, Object>();
        mapImg.put(0,label21);
        mapImg.put(1,label22);
        mapImg.put(2,label23);
        HashMap<Integer,Object> mapName=new HashMap<Integer, Object>();
        mapName.put(0,label8);
        mapName.put(1,label11);
        mapName.put(2,label14);
        HashMap<Integer,Object> mapNum=new HashMap<Integer, Object>();
        mapNum.put(0,label9);
        mapNum.put(1,label12);
        mapNum.put(2,label15);



        ImageIcon  icon1 = new ImageIcon(relativePath+"img4.png");
        ImageIcon  icon2 = new ImageIcon(relativePath+"img5.png");
        ImageIcon  icon3 = new ImageIcon(relativePath+"img6.png");
        icon1.setImage(icon1.getImage().getScaledInstance(60,60,Image.SCALE_DEFAULT));
        icon2.setImage(icon2.getImage().getScaledInstance(60,60,Image.SCALE_DEFAULT));
        icon3.setImage(icon3.getImage().getScaledInstance(60,60,Image.SCALE_DEFAULT));

        label6.setText(packsack.getUserscore()+"");


        for(int i=0;i<packsack.getPropList().size();i++){
            String propName = packsack.getPropList().get(i).getPropName();
            String propDesc = packsack.getPropList().get(i).getPropDesc();
            long propNum = packsack.getPropList().get(i).getPropNum();

            if(propName.equals("杀棋")){
                ((JLabel)mapImg.get(i)).setIcon(icon1);
            }else if(propName.equals("变色棋")){
                ((JLabel)mapImg.get(i)).setIcon(icon2);
            }else {
                ((JLabel)mapImg.get(i)).setIcon(icon3);
            }

            ((JLabel)mapName.get(i)).setText("<html>"+propName+": "+propDesc+"</html>");
            ((JLabel)mapNum.get(i)).setText("X"+propNum);
        }



//        label21.setIcon(icon1);
//        label22.setIcon(icon2);
//        label23.setIcon(icon3);

        setVisible(true);


    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JPanel panel1;
    private JLabel label5;
    private JLabel label6;
    private JLabel label7;
    private JPanel panel2;
    private JLabel label21;
    private JLabel label9;
    private JLabel label8;
    private JPanel panel3;
    private JLabel label22;
    private JLabel label11;
    private JLabel label12;
    private JPanel panel4;
    private JLabel label23;
    private JLabel label14;
    private JLabel label15;
    private JLabel label4;
    private JButton button1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
